package com.fy.controller;

import com.fy.dao.SearchMapper;
import com.fy.entity.Ac_info;
import com.fy.entity.Fy_info;
import com.fy.entity.Goods;
import com.fy.entity.Search;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {
    String id = "1";
    @Resource
    SearchMapper searchMapper;


    @GetMapping("/getAll")
    public List<Search> findAll() {
        return searchMapper.findAll();
    }

    @PostMapping("/getInfo")
    public List<Search> getInfo(String info_id) {
        return searchMapper.getInfo(info_id);
    }

    @PostMapping("/insert")
    public int insert(String s_id, String s_info, String info_id) {
        searchMapper.insert(id, info_id, s_info);
        id = (Integer.valueOf(id) + 1 + "");
        return 200;
    }

    @PostMapping("/delete")
    public int delete(String s_id) {
        return searchMapper.delete(s_id);
    }

    @PostMapping("/searchAc")
    public List<Ac_info> search1(String name) {
        return searchMapper.SearchAcByName(name);
    }

    @PostMapping("/searchGo")
    public List<Goods> search2(String name) {
        return searchMapper.SearchGoByName(name);
    }

    @PostMapping("/searchFy")
    public List<Fy_info> search3(String name) {
        return searchMapper.SearchFyByName(name);
    }

}
